<template>
  <div class="container">
    <div class="title">绑定银行卡</div>
    <div class="card" v-show="bool" @click="addCard()">
      添加银行卡<van-icon name="plus" style="margin: 2.5px 0 0 10px" />
    </div>
    <div class="card" @click="addCard(index)" v-for="(item, index) in data" :key="index">
      <img :src="item.qrcode_url" alt="" srcset="" />
      <div class="content">
        <div>
          账户姓名：<span>{{ item.username }}</span>
        </div>
        <div style="margin-top: 10px">
          银行卡号：<span>{{ item.banknum }}</span>
        </div>
      </div>
    </div>
    <div class="text">
      <div>为确保能一次性通过审核，请按如下几点上传:</div>
      <div>1，所有收款方式的实名信息必须和要提交实名认证的实名一致。</div>
      <div>2，一定要认真填写银行卡收款信息。</div>
      <div>
        ***请认真填写并上传收款方式，一旦通过审核，不得再修改和添加，银行卡收款方式不允许关闭***
      </div>
    </div>
  </div>
</template>

<script>
import { getCard, imgUrl } from '../../api/api'
export default {
  data() {
    return {
      data: [],
      bool: true,
    };
  },
  methods: {
    addCard(index) {
      let data
      this.data[index] == null || undefined ? data = null : data = this.data[index]
      this.$router.push({
        name: "addCard",
        query: {
          data: JSON.stringify(data)
        },
      });
    },
    getUserCard() {
      let data = {
        user_id: localStorage.getItem('userId')
      }
      getCard(data).then(res => {
        this.$toast.clear()
        res.data.rows.forEach(item => {
          item.qrcode_url = imgUrl + item.qrcode_url
        })
        console.log('获取银行卡列表接口回调---', res.data)
        res.data.rows != [] ? this.bool = true : this.bool = false
        if(res.data.rows.length == 0) return
        this.bool = false
        this.data = res.data.rows
      })
    },
  },
  mounted() {
    this.getUserCard()
  },
};
</script>

<style lang="less" scoped>
div {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
.container {
  background-color: #f1f1f1;
  min-height: 100vh;
  .title {
    width: 100%;
    height: 60px;
    text-align: center;
    line-height: 60px;
    font-size: 1.2em;
    background-color: #fff;
  }
  .card {
    margin-top: 10px;
    width: 92%;
    margin-left: 4%;
    height: 100px;
    background-color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #3ace8a;
    font-size: 1.1em;
    font-weight: 700;

    img {
      height: 80%;
    }

    .content {
      width: calc(100% - 120px);
      height: 100%;
      margin-left: 20px;
      font-size: 0.8em;
      font-weight: 600;
      color: #999999;
      display: flex;
      flex-direction: column;
      justify-content: center;

      span {
        color: #333333;
      }
    }
  }
  .text {
    margin-top: 10px;
    width: 92%;
    margin-left: 4%;
    color: #333333;
    font-size: 0.7em;
    line-height: 20px;
    letter-spacing: 1px;

    div {
      margin-top: 10px;
    }
  }
}
</style>